export default {
  namespaced: true,
  state: () => ({
    address: JSON.parse(uni.getStorageSync('address') || '{}'),
    token: '123456789',
    userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}'),
  }),
  mutations: {
    updataAddress(state, value) {
      state.address = value
      uni.setStorageSync('address', JSON.stringify(value))
    },
    updataUserInfo(state, value) {
      state.userInfo = value
      uni.setStorageSync('userInfo', JSON.stringify(value))
    },
    saveToken(state, value) {
      state.token = value;
      uni.setStorageSync('token', JSON.stringify(value))
    }
  },
  getters: {
    addressStr(state) {
      let obj = state.address
      return obj.provinceName + obj.cityName + obj.countyName + obj.detailInfo;
    }
  }
}
